package server;

import server.config.Server;

import java.io.InputStream;

/**
 * 映射器，用于将URL映射到Servlet
 */
public class Mapper {
    /**
     * Server配置
     */
    private Server server;

    /**
     * 根据给定的URL，获取对应的Servlet
     *
     * @param url 给定的URL
     * @return 对应的Servlet
     */
    public HttpServlet resolveServlet(String url) {
        return server.resolveServlet(url);
    }

    /**
     * 根据给定的URL，获取对应的静态资源
     *
     * @param url 给定的URL
     * @return 对应的静态资源
     */
    public InputStream resolveStatic(String url) {
        return server.resolveStatic(url);
    }

    public Server getServer() {
        return server;
    }

    public void setServer(Server server) {
        this.server = server;
    }
}
